using System;
using System.Collections.Generic;
using System.Text;

namespace PaulRz.Util.Patterns
{

    public abstract class TerminatorPipelineElement<TInput, TOutput> : PipelineElement<TInput, TOutput>
        where TInput : class
        where TOutput : class 
    {
        protected TerminatorPipelineElement(string name, ILogInterface logger, int joinTime) : base(name, logger, joinTime)
        {
        }

        protected ProducerPipelineElement<TOutput>[] producers;
        protected ConsumerPipelineElement<TInput>[] consumers;
        
        /// <summary>
        /// The main point is that producing pipeline should be finished at the moment of attachment.
        /// </summary>
        /// <param name="producing"></param>
        /// <param name="consuming"></param>
        public void AttachToPipelines(Pipeline producing, Pipeline consuming)
        {
            producing.AddConsumer(consumers);
            Input = consumers[0].Input;
            consuming.AddProducer(producers);
            Output = producers[0].Output;
        }
    }
}
